var pie_sale = echarts.init(document.getElementById('pie_sale'), 'shine');
var line_luntai = echarts.init(document.getElementById('line_luntai'), 'shine');
var pie_all = echarts.init(document.getElementById('pie_all'), 'shine');
var pie_ban = echarts.init(document.getElementById('pie_ban'), 'shine');
var pie_day = echarts.init(document.getElementById('pie_day'), 'shine');
var line_peitai = echarts.init(document.getElementById('line_peitai'), 'shine');
var line_Liuhuachxing = echarts.init(document.getElementById('line_Liuhuachxing'), 'shine');
var line_LiuhuachxingCl = echarts.init(document.getElementById('line_LiuhuachxingCl'), 'shine');
var bar_store = echarts.init(document.getElementById('bar_store'), 'shine');
var isCarousel = true;
var dindex = 0;
window.onload = function() {
	var timer = setInterval(function() {
		$("#time").html(utils.GetDateTime("yyyy-MM-dd HH:mm:ss"));
	}, 1000)
	pie_sale.setOption(option.getPieSale());
	pie_all.setOption(option.getGauge({
		series: [{
			name: "当日进仓完成率",
			data: [{
				value:Math.round(utils.CalcCurNum(18800,0)*10000/18800)/100,
				name: "当日进仓"
			}]
		}]
	}));
	pie_ban.setOption(option.getGauge({
		series: [{
			name: "当班硫化完成率",
			data: [{
				value:Math.round(utils.CalcCurTeamNum(18496,0)*10000/6166)/100,
				name: "当班硫化"
			}]
		}]
	}));
	pie_day.setOption(option.getGauge({
		series: [{
			name: "当日硫化完成率",
			data: [{
				value:Math.round(utils.CalcCurNum(18496,0)*10000/18496)/100,
				name: "当日硫化"
			}]
		}]
	}));
	line_peitai.setOption(option.getLine({
		title: {
			text: '单位：条'
		},
		legend: {
			data: ['胎胚库存']
		},
		xAxis: {
			data: utils.GetTimeInterval(24, "hour")
		},
		series: [{
			data: utils.GetNumInterval(24, 2000, 1000)
		}]
	}));
	line_LiuhuachxingCl.setOption(option.getLine({
		title: {
			text: '单位：条'
		},
		legend: {
			data: ['成型产量', '硫化产量']
		},
		xAxis: {
			data: utils.GetTimeInterval(10, "day")
		},
		series: [{
			data: utils.GetNumInterval(10, 20000, 3000)
		}, {
			data: utils.GetNumInterval(10, 20000, 3000)
		}]
	}));
	line_Liuhuachxing.setOption(option.getGridLine({
		title: {
			text: '单位：分钟'
		},
		legend: {
			data: ['成型节拍', '硫化节拍']
		},
		xAxis: [{
			data: utils.GetTimeInterval(24, "hour")
		}, {
			data: utils.GetTimeInterval(24, "hour")
		}],
		yAxis: [{
			max: 8,
			min: 4
		}, {
			max: 56,
			min: 44
		}],
		series: [{
			name: '成型节拍',
			data: utils.GetNumInterval(24, 6, 2)
		}, {
			name: '硫化节拍',
			data: utils.GetNumInterval(24, 50, 6)
		}]
	}));
	line_luntai.setOption(option.getGridLine({
		title: {
			text: '单位：%'
		},
		legend: {
			data: ['公司', '老线', '全钢一']
		},
		xAxis: [{
			data: utils.GetTimeInterval(22, "day")
		}, {
			data: utils.GetTimeInterval(22, "day")
		}],
		yAxis: [{
			max: 100,
			min: 98
		}, {
			max: 100,
			min: 98
		}],
		series: [{
			name: '公司',
			data: [99.11, 99.22, 99.95, 99.94, 99.11, 99.94, 99.10, 99.03, 99.25, 99.34, 99.35, 99.51, 99.40, 99.54, 99.51, 99.48, 99.51, 99.36, 99.29, 99.27, 99.00, 99.23],
		}, {
			name: '老线',
			data: [99.07, 99.95, 99.71, 99.74, 99.87, 99.80, 99.92, 99.85, 99.08, 99.26, 99.35, 99.48, 99.39, 99.43, 99.47, 99.54, 99.55, 99.34, 99.31, 99.28, 98.98, 99.13],
		}, {
			name: '全钢一',
			data: [99.20, 99.69, 99.38, 99.28, 99.55, 99.21, 99.44, 99.35, 99.58, 99.49, 99.36, 99.57, 99.43, 99.74, 99.58, 99.35, 99.43, 99.40, 99.25, 99.26, 99.05, 99.43],
		}]
	}));
	diCarousel();
	var mytimer = setInterval("diCarousel()", 5000); //1000为1秒钟
};
window.onresize = function() {
	pie_sale.resize();
	line_luntai.resize();
	pie_ban.resize();
	pie_all.resize();
	pie_day.resize();
	bar_store.resize();
	line_peitai.resize();
	line_Liuhuachxing.resize();
	line_LiuhuachxingCl.resize();
};

function diCarousel() {
	if (!isCarousel) {
		return;
	}
	dindex++;
	options = option.getStoreBar();
	switch (dindex) {
		case 1:
			options.xAxis[0].data = utils.GetTimeInterval(10, "day");
			options.series[0].data = utils.GetNumInterval(10, 19000, 2000);
			title = "朝阳正品进仓产量(日-近10天)";
			break;
		case 2:
			options.xAxis[0].data = utils.GetTimeInterval(12, "month");
			options.series[0].data = utils.GetNumInterval(12, 19000 * 30, 2000 * 30);
			title = "朝阳正品进仓产量(月-连续12个月)";
			break;
		case 3:
			options.xAxis[0].data = utils.GetTimeInterval(6, "year");
			options.series[0].data = utils.GetNumInterval(6, 19000 * 12 * 30, 2000 * 12 * 30);
			title = "朝阳正品进仓产量(年-近6年)";
			dindex = 0;
			break;
	}
	bar_store.clear();
	bar_store.setOption(options);
	document.getElementById('myh2').innerHTML = title;
}